package com.yflutter.yfree_app.util

import com.yflutter.yfree_app.lib.YFree.YUniappPlugin
import com.yfree.activities.YActivity
import io.dcloud.feature.unimp.DCUniMPJSCallback

class MiniAppUtils {
    companion object {
        fun callback_base(activity: YActivity, event: String, data: Any?, callback: DCUniMPJSCallback) {
            when (event) {
                "yGetHttpHeader" -> {
                    callback("""{
                        "myHeader": "value1"
                    }""")
                }
            }
        }

        fun goMiniApp(activity: YActivity, checkVersionJkid: String) {
            YUniappPlugin(activity, checkVersionJkid = checkVersionJkid) { appid, event, data, callback ->
                when (event) {
                    "myFunc1" ->
                        MyPlugin.yFlutter.yToast("自定义扩展函数：myFunc1")
                    else -> callback_base(activity, event, data, callback)
                }
            }.run()
        }
    }
}